//
// Created by Hoyin on 2024/4/15.
//

#ifndef VISUAL_LOCATION_PARTIDETECTOR_H
#define VISUAL_LOCATION_PARTIDETECTOR_H

#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/features2d.hpp>

template <class T>
class PartiDetector {
private:
	std::vector<cv::Rect> _rois;
	cv::Mat _mask;
	cv::Ptr<T> _detector;
	std::vector<cv::KeyPoint> _keypoints;
	uint32_t _hParts, _vParts;
	uint32_t _nFeatures;

public:
	/**
	 * 分块特征检测
	 * @param detector 预先定义的检测器
	 * @param hParts 水平分块数
	 * @param vParts 垂直分块数
	 */
	PartiDetector(cv::Ptr<T> &detector, uint32_t hParts=1, uint32_t vParts=1) :
	_hParts(hParts), _vParts(vParts) {
		_detector = detector;
	}

	/**
	 * 分块特征检测
	 * @param src 图像输入
	 * @param keypoints 特征点输出
	 */
	void detect(const cv::Mat &src, std::vector<cv::KeyPoint> &keypoints);

	/**
	 * 返回所有ROI矩形
	 * @return
	 */
	inline std::vector<cv::Rect> getROIs() {
		return _rois;
	}
};


#endif //VISUAL_LOCATION_PARTIDETECTOR_H
